//  CommandControl.cpp  Class to control the RFBee based on the command 
//  received from the remote.
//  see http://www.seeedstudio.com/depot/ for details on the relayshield

//  Copyright (c) 2010 Icing Chang at www.seeedstudio.com
//  Author: Icing Chang
//  Version: August 31, 2010
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

#ifndef _COMMANDCONTROL_H
#define _COMMANDCONTROL_H 1
#include <string.h>
#include <ctype.h>

#include "WProgram.h"
#include "debug.h"
#include "CCx.h"

#define RX_BUFFER_LEN 100
class CommandControl
{
  public:
  CommandControl(void);
  CommandControl(byte *initCmdHead,byte initCmdHeadLen, byte initCmdLen,void (*initExecuteCmd)(byte *cmdRawData));
  ~CommandControl();
  void parseCmd(byte *rxData, byte rxLen);
  private:
  int findCmd();
  void processCmd(byte headPos);
  void (*executeCmd)(byte *cmdRawData);
  
  public:
  byte rxBuffer[RX_BUFFER_LEN];
  byte rxLenInBuffer;
  byte *cmdHead;
  byte cmdHeadLen;
  byte cmdLen;
};

#endif
